#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <cctype>
#include <set>

namespace uvu
{
#define LOCAL ____________DONT_DEFINE_ME____________
#define ll long long
#define inf 0x3f3f3f3f
// #define int long long
// #define inf 0x3f3f3f3f3f3f3f3fll
#define infll 0x3f3f3f3f3f3f3f3fll
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define gline debug("now is #%d\n", __LINE__)
#define pii std::pair <int, int>
#define mkp std::make_pair
#define fi first
#define se second
char _ST_;
const int BUFSIZE = (1 << 20);
char ibuf[BUFSIZE], *iS = ibuf, *iT = ibuf;
char obuf[BUFSIZE], *oS = obuf, *oT = obuf + BUFSIZE;
char getc()
{
#ifdef LOCAL
	return getchar();
#else
	if(iS == iT) iT = (iS = ibuf) + fread(ibuf, 1, BUFSIZE, stdin);
	return iS == iT ? EOF : *iS++;
#endif
#define getchar ERR
}

void Flush() { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; }
struct Flusher { ~Flusher(){ Flush(); } }iamflusher;

void putc(char c)
{
#ifdef LOCAL
	putchar(c);
#else
	*oS++ = c;
	if(oS == oT) Flush();
#endif
#define putchar ERR
}

template <typename T = int> T read()
{
	T x = 0, f = 1; char c = getc();
	for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
	for(;  isdigit(c); c = getc()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

template <typename T> void print(T x, char c)
{
static int sta[BUFSIZE], top;
	top = 0;
	if(x < 0) putc('-'), x = -x;
	if(!x) sta[top = 1] = 0;
	for(; x; x /= 10) sta[++top] = x % 10;
	for(; top; ) putc(sta[top--] ^ 48);
	if(c) putc(c);
}

int readstr(char *s, int base)
{
	int idx = base - 1; char c = getc();
	for(; !(isdigit(c) || isalpha(c) || c == '#' || c == '.'); c = getc());
	for(;   isdigit(c) || isalpha(c) || c == '#' || c == '.' ; c = getc()) s[++idx] = c;
	return idx - base + 1;
}

void printf(const char *s) { for(; *s; s++) putc(*s); }
template <typename T, typename ... Args>
void printf(const char *s, T x, Args ... rest)
{
	for(; *s; s++)
	{
		if(*s != '%') { putc(*s); continue; }
		s++; if(*s == 'd') print(x, 0);
		else if(*s == 'c') putc(x);
		printf(s + 1, rest ...);
		return;
	}
}

template <typename T> void ckmax(T &x, T y) { x = x > y ? x : y; }
template <typename T> void ckmin(T &x, T y) { x = x < y ? x : y; }
#define mod 998244353
// #define mod 1000000007
int sm(int x) { return x >= mod ? x - mod : x; }
void plus_(int &x, int y) { x = sm(x + y); }
void mul_(int &x, int y) { x = 1ll * x * y % mod; }
int ksm(int a, int b) { int res = 1; for(; b; b >>= 1, mul_(a, a)) if(b & 1) mul_(res, a); return res; }

#define N 1200010
int m, n;
int op_[N];
char str[2];

namespace T1
{
struct Tree
{
	int mx, L, R;
	int lazy;
	void push(int z) { mx += z, lazy += z; }
}tr[N << 2];
#define root 1, 0, 1100000
#define lson k << 1
#define rson k << 1 | 1
#define ls lson, l, mid 
#define rs rson, mid + 1, r 
void pushdown(int k) { if(tr[k].lazy) tr[lson].push(tr[k].lazy), tr[rson].push(tr[k].lazy), tr[k].lazy = 0; }
void pushup(int k)
{
	if(tr[lson].mx < tr[rson].mx) tr[k].mx = tr[rson].mx, tr[k].L = tr[rson].L, tr[k].R = tr[rson].R;
	if(tr[lson].mx > tr[rson].mx) tr[k].mx = tr[lson].mx, tr[k].L = tr[lson].L, tr[k].R = tr[lson].R;
	if(tr[lson].mx == tr[rson].mx) tr[k].mx = tr[lson].mx, tr[k].L = tr[lson].L, tr[k].R = tr[rson].R;
}
void build(int k, int l, int r)
{
	if(l == r) { tr[k].mx = 0; tr[k].L = tr[k].R = r; return; }
	int mid = (l + r) >> 1; build(ls); build(rs); pushup(k);
}
void change(int k, int l, int r, int ql, int qr, int z)
{
	if(ql <= l && r <= qr) return tr[k].push(z);
	int mid = (l + r) >> 1; pushdown(k);
	if(ql <= mid) change(ls, ql, qr, z);
	if(mid < qr)  change(rs, ql, qr, z);
	pushup(k);
}
}
const int lim = 2000000;
namespace T2
{
struct Tree
{
	int mx, mn, val;
}tr[N << 2];
void build(int k, int l, int r)
{
	tr[k].mx = -lim, tr[k].mn = lim, tr[k].val = 2 * lim;
	if(l == r) return;
	int mid = (l + r) >> 1; build(ls); build(rs);
}
void pushup(int k, int l, int r, int mid)
{
	tr[k].mx = std::max(tr[lson].mx, tr[rson].mx);
	tr[k].mn = std::min(tr[lson].mn, tr[rson].mn);
	tr[k].val = std::min({tr[lson].val, tr[rson].val, tr[rson].mn - tr[lson].mx});
}
void updatemn(int k, int l, int r, int q, int z)
{
	if(l == r) { tr[k].mn = z; tr[k].val = 2 * lim; /* tr[k].mn - tr[k].mx */; return; }
	int mid = (l + r) >> 1; q <= mid ? updatemn(ls, q, z) : updatemn(rs, q, z);
	pushup(k, l, r, mid);
}
void updatemx(int k, int l, int r, int q, int z)
{
	if(l == r) { tr[k].mx = z; tr[k].val = 2 * lim; /* tr[k].mn - tr[k].mx */; return; }
	int mid = (l + r) >> 1; q <= mid ? updatemx(ls, q, z) : updatemx(rs, q, z);
	pushup(k, l, r, mid);
}
}
std::multiset <int> sL[N], sR[N];

void solve()
{
	// memset(h, idx = -1, sizeof(h));
	m = read(); T1::build(root); T2::build(root);
	for(int i = 1, l, r; i <= m; i++)
	{
		readstr(str, 0); l = read(), r = read() - 1;
		// if(i == 7094) debug("%c [%d %d]\n", str[0], l, r);
		if(str[0] == 'A')
		{
			n++; T1::change(root, l, r, 1);
			sL[l].insert(r); sR[r].insert(l);
		}
		else
		{
			n--; T1::change(root, l, r, -1);
			sL[l].erase(sL[l].find(r)); sR[r].erase(sR[r].find(l));
		}
		if(sL[l].empty()) T2::updatemn(root, l, lim);
		else T2::updatemn(root, l, *sL[l].begin());
		if(sR[r].empty()) T2::updatemx(root, r, -lim);
		else T2::updatemx(root, r, *sR[r].rbegin());
		if(T1::tr[1].mx == n)
		{
			// printf("A ");
			// gline;
			int l = T1::tr[1].L, r = T1::tr[1].R;
			// if(sL[l].empty()) gline;
			// if(sR[r].empty()) gline;
			print(*sL[l].begin() - *sR[r].rbegin() + 1, '\n');
		}
		else
		{
			// gline;
			// printf("B ");
			print(T2::tr[1].val + 1, '\n');
		}
	}
}

void init()
{

}

char _ED_;

void mian()
{
	debug("%.3f MB\n", abs(&_ST_ - &_ED_) / 1024.0 / 1024);
	init();
	for(int T = 1; T; solve(), T--);
}

#ifdef int
	#undef int
#endif
}

int main()
{
	freopen("stone.in", "r", stdin);
	freopen("stone.out", "w", stdout);
	uvu::mian(); return 0;
}